from datetime import datetime
import sys
import re
import logging as l


"""
两种表示位置的类，一种表示#开始的kindle中的位置
一种表示PDF中的页码
"""
class KindleRange:
    def __init__(self, start, end=None):
        self.start = start
        self.end = end

    def __str__(self):
        if self.end is not None:
            return f'#{self.start}-{self.end}'
        return f'#{self.start}'

    def export(self):
        """写回kindle时的字符串"""
        if self.end is not None:
            return f'位置 #{self.start}-{self.end}'
        return f'位置 #{self.start}'

class PageRange:
    def __init__(self, start, end=None):
        self.start = start
        self.end = end

    def __str__(self):
        if self.end is not None:
            return f'{self.start}-{self.end}'
        return f'{self.start}'

    def export(self):
        """写回kindle时的字符串"""
        if self.end is not None:
            return f'第 {self.start}-{self.end} 页'
        return f'第 {self.start} 页'

class Note:
    def __init__(self):
        self.book = None    # 书名
        self.time = None    # 时间
        self.content = None # 内容
        self.position = None    # 位置

    def __str__(self):
        return '({},{},{})'.format(self.book, self.time, self.position)
    def __repr__(self):
        return self.__str__()
    def export(self):
        raise NotImplemented()

class Highlighting(Note):
    pass

class Comment(Note):
    pass

class Bookmark(Note):
    pass
